﻿<Window x:Class="MoPlus.SolutionBuilder.WpfClient.UserControls.FindReplaceDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:lib="clr-namespace:MoPlus.SolutionBuilder.WpfClient.Library"
        xmlns:Settings="clr-namespace:MoPlus.SolutionBuilder.WpfClient.Library;assembly=MoPlus.SolutionBuilder.WpfClient"
		xmlns:diag="clr-namespace:MoPlus.SolutionBuilder.WpfClient.UserControls.Interpreter"
        Title="{Binding FindAndReplaceLabel}" Height="Auto" MinWidth="350" MaxWidth="1200" Width="Auto" ResizeMode="NoResize"  SizeToContent="WidthAndHeight"  KeyDown="Window_KeyDown" WindowStyle="ToolWindow" ShowInTaskbar="False" Topmost="True"
        FocusManager.IsFocusScope="True">
    <Window.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="../Resources/Theme.xaml" />
			</ResourceDictionary.MergedDictionaries>
			<lib:SearchScopeToInt x:Key="searchScopeToInt"/>
			<BooleanToVisibilityConverter x:Key="boolToVis" />
			<DataTemplate x:Key="FindPageTemplate">
				<StackPanel>
					<ContentPresenter Content="{Binding }" />
					<StackPanel DataContext="{Binding DataContext}">
						<TextBlock Margin="3" Visibility="{Binding ShowSearchIn,Converter={StaticResource boolToVis}}" Text="{Binding SearchInLabel}"/>
						<ComboBox SelectedIndex="{Binding SearchIn, Mode=TwoWay,Converter={StaticResource searchScopeToInt}}" Margin="0 0 0 3" 
                              Visibility="{Binding ShowSearchIn,Converter={StaticResource boolToVis}}"
                              HorizontalAlignment="Stretch">
							<ComboBoxItem Content="{Binding CurrentDocumentLabel}"/>
							<ComboBoxItem Content="{Binding AllDocumentsLabel}"/>
						</ComboBox>
						<Expander Header="{Binding OptionsLabel}" IsExpanded="False">
							<StackPanel>
								<CheckBox Margin="1" Name="chkCaseSensitive" IsChecked="{Binding CaseSensitive, Mode=TwoWay}" Content="{Binding CaseSensitiveLabel}"/>
								<CheckBox Margin="1" Name="chkSearchUp" IsChecked="{Binding SearchUp, Mode=TwoWay}" Content="{Binding SearchUpLabel}"/>
								<CheckBox Margin="1" Name="chkWholeWord" IsChecked="{Binding WholeWord, Mode=TwoWay}" Content="{Binding WholeWordLabel}"/>
								<CheckBox Margin="1" Name="chkRegex" IsChecked="{Binding UseRegEx, Mode=TwoWay}" Content="{Binding UseRegExLabel}"/>
								<CheckBox Margin="1" Name="chkWildcards" IsChecked="{Binding UseWildcards, Mode=TwoWay}" Content="{Binding UseWildcardsLabel}"/>
							</StackPanel>
						</Expander>
					</StackPanel>
				</StackPanel>
			</DataTemplate>
		</ResourceDictionary>
	</Window.Resources>
	<Grid RenderTransformOrigin="0.5,0.5">
		<Grid.LayoutTransform>
			<TransformGroup>
				<ScaleTransform ScaleX="{Binding Source={x:Static Settings:UserSettingsHelper.Instance}, Path=ControlSize, Mode=TwoWay}"
					                             ScaleY="{Binding Source={x:Static Settings:UserSettingsHelper.Instance}, Path=ControlSize, Mode=TwoWay}"/>
			</TransformGroup>
		</Grid.LayoutTransform>
		<TabControl Name="tabMain" Height="Auto">
			<TabItem Header="{Binding FindTabLabel}" Name="tabFind" IsSelected="True" Style="{DynamicResource FixedTabItem}" ContentTemplate="{StaticResource FindPageTemplate}">
                <StackPanel>
					<TextBlock Margin="3" Text="{Binding TextToFindLabel}"/>
					<TextBox Margin="3" Name="txtFind" AcceptsReturn="{Binding AcceptsReturn}" Text="{Binding TextToFind, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
					<Button Margin="3" IsDefault="True" HorizontalAlignment="Right" Click="FindNextClick" Content="{Binding FindNextLabel}"/>
                </StackPanel>
            </TabItem>
			<TabItem Header="{Binding ReplaceTabLabel}" Name="tabReplace" Style="{DynamicResource FixedTabItem}" ContentTemplate="{StaticResource FindPageTemplate}">
                <StackPanel>
					<TextBlock Margin="3" Text="{Binding TextToFindLabel}"/>
					<TextBox Margin="3" Name="txtFind2" AcceptsReturn="{Binding AcceptsReturn}" Text="{Binding TextToFind, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
					<TextBlock Margin="3" Text="{Binding ReplaceWithLabel}"/>
					<TextBox Margin="3" Name="txtReplace" AcceptsReturn="{Binding AcceptsReturn}" Text="{Binding ReplacementText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
						<Button IsDefault="True" Margin="3" HorizontalAlignment="Right" Click="FindNextClick" Content="{Binding FindNextLabel}"/>
						<Button Margin="3" HorizontalAlignment="Right" Click="ReplaceClick" Content="{Binding ReplaceLabel}"/>
						<Button Margin="3" HorizontalAlignment="Right"  Click="ReplaceAllClick" Content="{Binding ReplaceAllLabel}"/>
					</StackPanel>
                </StackPanel>
            </TabItem>
        </TabControl>
    </Grid>
</Window>
